var t, a = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), e = require("../../../@babel/runtime/helpers/asyncToGenerator"), o = getApp(), n = require("../../../mybehaviors/location/location");

Page({
    behaviors: [ n ],
    data: {
        active: 0,
        address: "",
        city: "",
        point: "",
        title: "",
        worker_id: "",
        worker: "",
        store: "",
        projects: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        titleInfo: "",
        commentList: [],
        pullDownBtnShow: !0
    },
    onLoad: (t = e(a.default.mark(function t(e) {
        var o = this;
        return a.default.wrap(function(t) {
            for (;;) switch (t.prev = t.next) {
              case 0:
                this.setData({
                    worker_id: e.worker_id
                }), e.point ? (this.setData({
                    point: JSON.parse(e.point)
                }), this.getData()) : this._getLocation(function() {
                    return o.getData();
                });

              case 2:
              case "end":
                return t.stop();
            }
        }, t, this);
    })), function(a) {
        return t.apply(this, arguments);
    }),
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    toshowAppointment: function(t) {
        wx.navigateTo({
            url: "/packageE/appointment/showAppointment/showAppointment?worker_id=" + this.data.worker.id
        });
    },
    swichTabTItem: function(t) {
        this.setData({
            active: t.detail.index
        }), 2 == this.data.active && 0 == this.data.commentList.length && this.getComment();
    },
    toRouter: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageC/o2o/HomeSeller/HomeSeller?store_id=" + a
        });
    },
    goProject: function(t) {
        var a = t.currentTarget.dataset.id, e = JSON.stringify(this.data.point);
        wx.navigateTo({
            url: "/packageE/appointment/ProjectDetails/ProjectDetails?project_id=" + a + "&point=" + e
        });
    },
    pullDownBtn: function() {
        this.setData({
            pullDownBtnShow: !this.data.pullDownBtnShow
        });
    },
    getComment: function() {
        var t = this, a = o.getNetAddresss("plugin.appointment.frontend.comment.get-comment-by-worker-id");
        o._getNetWork({
            url: a,
            data: {
                page: this.data.page,
                worker_id: this.data.worker_id
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page,
                    commentList: e.data.data
                }), t.data.total_page || t.setData({
                    total_page: 0
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            });
            var e = o.getNetAddresss("plugin.appointment.frontend.comment.get-comment-by-worker-id");
            o._getNetWork({
                url: e,
                data: {
                    page: this.data.page,
                    worker_id: this.data.worker_id
                },
                success: function(a) {
                    var e = a.data;
                    if (1 == e.result) {
                        var o = e.data.data.concat(t.data.commentList);
                        t.setData({
                            commentList: o
                        });
                    } else {
                        wx.showToast({
                            title: e.msg,
                            icon: "none"
                        });
                        var n = t.data.page - 1;
                        t.setData({
                            page: n,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    getData: function() {
        var t = this, a = o.getNetAddresss("plugin.appointment.frontend.worker.get-detail-by-id");
        o._getNetWork({
            url: a,
            data: {
                lng: this.data.point.lng,
                lat: this.data.point.lat,
                worker_id: this.data.worker_id
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    worker: e.data.worker,
                    store: e.data.store,
                    projects: e.data.projects,
                    appointmentLang: wx.getStorageSync("yz_basic_info").lang.appointment
                }), wx.setNavigationBarTitle({
                    title: t.data.appointmentLang.worker + "详情"
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});